package com.lagou.seckill.mvc.advice;

import com.lagou.seckill.dto.Response;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class ExceptionAdvice {


    @ResponseBody
    @ExceptionHandler(Throwable.class)
    public Response onException(Throwable ex) {
        log.error(ex.getMessage(), ex);
        return Response.FAIL(ex.getMessage());
    }

}
